﻿Imports System.IO
Imports System.Net
Imports System.Text


Public Class WebHandler

    Public Shared Function GetIPAddresses() As String
        Dim builder As New StringBuilder

        Dim ip = Dns.GetHostEntry(Dns.GetHostName)

        builder.AppendLine(String.Format("Internal IP address:  {0}", ip.AddressList.GetValue(0).ToString()))
        Try
            Using client As New WebClient
                Dim externalIP = client.DownloadString("http://automation.whatismyip.com/n09230945.asp")
                builder.AppendLine(String.Format("External IP address:  {0}", externalIP.Trim()))
            End Using
        Catch ex As Exception
            builder.AppendLine(String.Format("Error retrieve external IP:  {0}", ex.Message))
        End Try

        Return builder.ToString
    End Function

End Class
